--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 151aa4c55f8be19034c9ee5257b23b86b0f21518
Parents : 3521ae6
Author : Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-05-05T23:08:14-05:00
feat(NotificationUtils): update notification handling for incoming calls, missed calls, voicemails, and messages on Android
Changes
1 files changed, 42 insertions(+), 5 deletions(-)
Diff
diff --git a/meshchatx/src/frontend/js/NotificationUtils.js b/meshchatx/src/frontend/js/NotificationUtils.js
index c9e5748b..c92d3705 100644
--- a/meshchatx/src/frontend/js/NotificationUtils.js
+++ b/meshchatx/src/frontend/js/NotificationUtils.js
@@ -1,14 +1,30 @@
class NotificationUtils {
- static showIncomingCallNotification() {
+ static _isAndroid() {
+ return Boolean(
+ typeof window !== "undefined" &&
+ window.MeshChatXAndroid &&
+ typeof window.MeshChatXAndroid.getPlatform === "function" &&
+ window.MeshChatXAndroid.getPlatform() === "android"
+ );
+ }
+
+ static showIncomingCallNotification(callerName) {
if (window.electron) {
- window.electron.showNotification("Incoming Call", "Someone is calling you.");
+ window.electron.showNotification(
+ "Incoming Call",
+ callerName ? `${callerName} is calling you.` : "Someone is calling you."
+ );
+ return;
+ }
+ if (NotificationUtils._isAndroid()) {
+ window.MeshChatXAndroid.showIncomingCallNotification(callerName || "Someone");
return;
}
Notification.requestPermission().then((result) => {
if (result === "granted") {
new window.Notification("Incoming Call", {
- body: "Someone is calling you.",
- tag: "incoming_telephone_call", // only ever show one incoming call notification at a time
+ body: callerName ? `${callerName} is calling you.` : "Someone is calling you.",
+ tag: "incoming_telephone_call",
});
}
});
@@ -19,6 +35,10 @@ class NotificationUtils {
window.electron.showNotification("Missed Call", `You missed a call from ${from}.`);
return;
}
+ if (NotificationUtils._isAndroid()) {
+ window.MeshChatXAndroid.showMissedCallNotification("Missed Call", `You missed a call from ${from}.`);
+ return;
+ }
Notification.requestPermission().then((result) => {
if (result === "granted") {
new window.Notification("Missed Call", {
@@ -34,6 +54,10 @@ class NotificationUtils {
window.electron.showNotification("New Voicemail", `You have a new voicemail from ${from}.`);
return;
}
+ if (NotificationUtils._isAndroid()) {
+ window.MeshChatXAndroid.showNotification("New Voicemail", `You have a new voicemail from ${from}.`);
+ return;
+ }
Notification.requestPermission().then((result) => {
if (result === "granted") {
new window.Notification("New Voicemail", {
@@ -52,15 +76,28 @@ class NotificationUtils {
);
return;
}
+ if (NotificationUtils._isAndroid()) {
+ window.MeshChatXAndroid.showNotification(
+ "New Message",
+ from ? `${from}: ${content || "Sent a message."}` : "Someone sent you a message."
+ );
+ return;
+ }
Notification.requestPermission().then((result) => {
if (result === "granted") {
new window.Notification("New Message", {
body: from ? `${from}: ${content || "Sent a message."}` : "Someone sent you a message.",
- tag: "new_message", // only ever show one new message notification at a time
+ tag: "new_message",
});
}
});
}
+
+ static cancelIncomingCallNotification() {
+ if (NotificationUtils._isAndroid()) {
+ window.MeshChatXAndroid.cancelIncomingCallNotification();
+ }
+ }
}
export default NotificationUtils;
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────